package com.funcourse.demo.sms.vcode;

import java.util.Date;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

/**
 * save information of verify code and the ident info such as phone/email
 * @author andrew.ren
 *
 */
@Data
@Document(collection="verifyCode")
public class VerifyCodeMongoBean {
    
    @Id
    private String id;
    
    private String ident;

    private String verifyCode;
    
    private Long expireTime;
    
    /**
     * to verify which function such as register/forget password
     */
    private VerifyCodeFunction function;
    public Boolean expired(){
        if(null == this.expireTime){
            return true;
        }
        return System.currentTimeMillis() > expireTime;
    }
}
